--攻守兼备
local gongshoujianbei = fk.CreateSkill {
    name = "mcdh_gongshoujianbei",
    tags = {Skill.Switch}
}

gongshoujianbei:addEffect('viewas',{
    pattern = "nullification",
    card_filter = function(self,player, to_select, selected)
        if #selected == 1 then return false end
        return Fk:getCardById(to_select).color == Card.Red
    end,
    view_as = function(self,player, cards)
        if #cards ~= 1 then return end
        local card = Fk:cloneCard("nullification")
        card.skillName = self.name
        card:addSubcard(cards[1])
        return card
    end,
    enabled_at_response = function (self, player, response)
        if player:usedEffectTimes(gongshoujianbei.name, Player.HistoryTurn) ~= 0 then
            return false
        end
        return not response and player:getSwitchSkillState(gongshoujianbei.name) == fk.SwitchYang
    end,
})

gongshoujianbei:addEffect(fk.TargetSpecified,{
    can_trigger = function (self, event, target, player, data)
        if player:usedEffectTimes(gongshoujianbei.name, Player.HistoryTurn) ~= 0  then
            return false
        end
        return player:hasSkill(self) and target == player and player:getSwitchSkillState(gongshoujianbei.name) == fk.SwitchYin
                and data.card.color == Card.Black and not data.to:isKongcheng() and data.to ~= player
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to =data.to
        local c = room:askForCardChosen(player, to, "h", self.name)
        room:obtainCard(player.id, c, false, fk.ReasonPrey)
    end
})

Fk:loadTranslationTable{
    ["mcdh_gongshoujianbei"] = "攻守",
    ["#mcdh_gongshoujianbei_yin"] = "攻守",
    [":mcdh_gongshoujianbei"] = "『攻守兼备』<br>转换技，每回合每项各限一次，①你可以将一张红色牌当做【无懈可击】使用；②当你使用黑色牌指定一个目标后，你可以获得其一张手牌。",
}

return gongshoujianbei